<?php

namespace app\company\model;

use app\common\model\BaseModel;
use app\common\model\Company;
use app\common\model\CompanyWarehouse;
use app\common\model\Dealer;
use app\common\model\Supplier;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;
use think\model\relation\HasOne;

class DealerOrder extends BaseModel
{
    public function detail(): HasMany
    {
        return $this->hasMany(DealerOrderDetail::class,'dealer_order_id','id');
    }

    public function company(): BelongsTo
    {
        return $this->belongsTo(Company::class,'company_id','id');
    }

    public function dealer(): BelongsTo
    {
        return $this->belongsTo(Dealer::class,'dealer_id','id');
    }

    public function warehouse(): BelongsTo
    {
        return $this->belongsTo(CompanyWarehouse::class,'company_warehouse_id','id');
    }

    public function supplier(): HasOne
    {
        return $this->hasOne(Supplier::class,'id','supplier_id');
    }
}